﻿@model IEnumerable<ESN.Models.GroupRequest>

@{
    ViewBag.Title = "Requests";
}
<script type="text/javascript">
    $(document).ready(function () {
        $('.fAccepted').click(function () {
            $.getJSON("/CoreService.svc/AcceptMemberRequest?r=" + $(this).attr('data-id'), function (result) {
                alert(result);
            });
        });
        $('.fDenied').click(function () {
            $.getJSON("/CoreService.svc/RejectMemberRequest?r=" + $(this).attr('data-id'), function (result) {
                alert(result);
            });
        });
    });
</script>
<h2>Requests</h2>

<table>
    <tr>
        <th></th>
        <th>By</th>
        <th>
            @Html.DisplayNameFor(model => model.GRHi)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.isInvite)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.GRTime)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td><img height="40" src="@item.Profile.Avatar" alt="*" /></td>
        <td>
            <a href="/@item.Profile.UserName/Home">@item.Profile.DisplayName</a>
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.GRHi)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.isInvite)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.GRTime)
        </td>
        <td><a data-id="@item.GRId" class="fAccepted">Accept</a>/<a data-id="@item.GRId" class="fDenied">Refuse</a></td>
    </tr>
}

</table>
